package day05.localDate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/25
 * 9.学生类：姓名，学号，出生日期  三个属性。找出比“张三”大的所有同学信息。
 */
public class Student {
    private String name;
    private String id;
    private LocalDate birthDate;

    // 构造函数接收解析好的 LocalDate 对象
    public Student(String name, String id, LocalDate birthDate) {
        this.name = name;
        this.id = id;
        this.birthDate = birthDate;
    }

    public LocalDate getBirthDate() {
        return birthDate;
    }

    @Override
    public String toString() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return "姓名: " + name + ", 学号: " + id + ", 出生日期: " + formatter.format(birthDate);
    }
}

 class StudentManager {
    public static void main(String[] args) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        // 解析日期字符串为 LocalDate 对象
        LocalDate birthDate1 = LocalDate.parse("2000-01-02", formatter);
        LocalDate birthDate2 = LocalDate.parse("2000-01-01", formatter);
        LocalDate birthDate3 = LocalDate.parse("2001-03-04", formatter);
        LocalDate birthDate4 = LocalDate.parse("1998-04-05", formatter);
        LocalDate birthDate5 = LocalDate.parse("2002-05-06", formatter);

        Student[] students = new Student[5];
        students[0] = new Student("张三", "001", birthDate1);
        students[1] = new Student("李四", "002", birthDate2);
        students[2] = new Student("王五", "003", birthDate3);
        students[3] = new Student("赵六", "004", birthDate4);
        students[4] = new Student("钱七", "005", birthDate5);

        System.out.println("比张三大年龄的同学信息如下：");
        for (int i = 1; i < students.length; i++) {
            if (students[i].getBirthDate().isBefore(birthDate1)) {
                System.out.println(students[i]);
            }
        }
    }
}
